Neuro Controller


Neuro Controller

A Neuro Controller is an Artificial Neural Network than has been trained to control a process. An ANN is useful in these cases because, it can usually interpolate to other cases that were not included during training. Additionally, the neuro controller can be easily reprogrammed using a new training set.

Problem 1
Create a New Project called Bob to build an appropriate training set for the neuro controller of the figure all inputs are from 0 to 2. Use your imagination to create the behavior of the neuro controller by completing the Microsoft Excel file shown below; try to be consistent in the behavior so that the ANN can be properly trained. Using Microsoft Excel to cut the training set input, paste it in a new document, and export it to the trainSetInput.csv file. Proceed in the same way to create the trainSetTarget.csv file.

NeuroController

BobMsExcel

Problem 2
Edit the Train.lab file to design and train an ANN for the Neuron Controller of problem 1. Use one hidden layer and adjust the number of neurons in this layer. Train the ANN appropriately.

Bob\Train.lab
//_________________________ Network Setup
LayerNet net;
net.Create(...);

//____________________________ Input Scaling
...
//____________________________ Output Scaling
...

//________________________ Load and set the training set
Matrix trainSetInput;
trainSetInput.Load();
Matrix trainSetTarget;
trainSetTarget.Load();
net.SetTrainSet(trainSetInput, trainSetTarget, false);

//________________________ Train
...

//_____________________________ Save the trained network
net.Save();

Problem 3
Edit the CheckTraining.lab file to check the training: (a) Compute the confusion matrix using the training set. (b) Plot the error for each network output. (c) Save the confusion matrix as a vector image (trainConf.emf).

trainConf

Problem 4
Perform the validation of the ANN by building a Dialog Application called Controller using Wintempla as shown.

Controller.h
#pragma once //______________________________________ Controller.h
#include "resource.h"

class Controller: public Win::Dialog
{
public:
     Controller()
     {
          action = 0;
     }
     ~Controller()
     {
     }
     int action;
     void Run();
     Nn::LayerNet network;
     CG::DDBitmap bitmapAttack;
     CG::DDBitmap bitmapEat;
     CG::DDBitmap bitmapHaveFun;
     CG::DDBitmap bitmapHide;
     CG::DDBitmap bitmapRun;
     CG::DDBitmap bitmapSleep;
protected:
     ...
};

Controller.cpp
#include "stdafx.h" //________________________________________ Controller.cpp
#include "Controller.h"

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR cmdLine, int cmdShow){
     Controller app;
     return app.BeginDialog(IDI_CONTROLLER, hInstance);
}

void Controller::Window_Open(Win::Event& e)
{
     //________________________________________________________ sldHungryLevel
     sldHungryLevel.SetRange(0, 100);
     ...

     //________________________________________________________ Load Bitmaps
     bitmapAttack.CreateFromResource(hInstance, IDB_ATTACK);
     ...

     this->picAction.SetImage(bitmapHaveFun);
}

void Controller::sldHungryLevel_Hscroll(Win::Event& e)
{
     Run();
}

void Controller::sldTireness_Hscroll(Win::Event& e)
{
     Run();
}

void Controller::sldNumbEnemies_Hscroll(Win::Event& e)
{
     Run();
}

void Controller::btSetAnn_Click(Win::Event& e)
{
     Win::FileDlg dlg;
     dlg.Clear();
     dlg.SetFilter(L"Layer Network files (*.lay)\0*.lay\0\0", 0, L"lay");
     if (dlg.BeginDialog(hWnd, L"Open", false))
     {
          const wchar_t* error = network.Load( dlg.GetFileNameFullPath());
          if (error != NULL)
          {
               this->MessageBox(error, L"Controller", MB_OK | MB_ICONERROR);
          }
     }
}

void Controller::Run()
{
     MATRIX input;
     Math::Oper::CreateMatrix(input, 1, 3);
     MATRIX output;
     ...
     if (network.Run(input, output) == false) return;
     double maximum = output[0][0];
     int winnerClass = 0;
     ..
     if (action == winnerClass) return; // Nothing to do
     action = winnerClass;
     switch(winnerClass)
     {
     ...
     }
}



InsertBitmaps

Attack

Eat

HaveFun

Hide

Run

Problem 5
Generate a report in Microsoft Word. Write some conclusions in the report focusing on the problems that were faced during the simulation and how these problems were or could be solved.

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home